package net.sunofbeaches.response;

public class ResponseResult {
    public ResponseResult(ResponseState responseState) {
        this.message = responseState.getMessage();
        this.success = responseState.isSuccess();
        this.data = responseState.getCode();
    }

    public static  ResponseResult GET(ResponseState state){
        return new ResponseResult(state);
    }

    public static ResponseResult SUCCESS(){
        return new ResponseResult(ResponseState.SUCCESS);
    }

    public static ResponseResult ACCOUNT_NOT_LOGIN(){
        return new ResponseResult(ResponseState.ACCOUNT_NOT_LOGIN);
    }

    public static ResponseResult PERMISSION_DENIED(){
        return new ResponseResult(ResponseState.PERMISSION_DENIED);
    }

    public static ResponseResult GET_RESOURCE_FAILED(){
        return new ResponseResult(ResponseState.GET_RESOURCE_FAILED);
    }

    public static ResponseResult SUCCESS(String message){
        ResponseResult success = SUCCESS();
        success.setMessage(message);
        return success;
    }

    public static ResponseResult FAILED() {
        return new ResponseResult(ResponseState.FAILED);
    }

    public static ResponseResult FAILED(String message) {
        ResponseResult failed = FAILED();
        failed.setMessage(message);
        return failed;
    }

    private String message;
    private boolean success;
    private int code;
    private Object data;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public ResponseResult setData(Object data) {
        this.data = data;
        return this;
    }
}
